package com.mygdx.game;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.mygdx.screen.EndScreen;
import com.mygdx.screen.MainScreen;
import com.mygdx.screen.StartScreen;

public class MyGdxGame extends Game {
    public static final float PPM = 100;
    public static final float GAME_WIDTH = 200;
    public static final float GAME_HEIGHT = 400;
    public static SpriteBatch batch;
    public static BitmapFont font;
    public FreeTypeFontGenerator generator;
    public static Integer defaultGameStatus = 0;//0:开始游戏 1:游戏中 2:游戏结束

    @Override
    public void create() {
        batch = new SpriteBatch();
        font = new BitmapFont(Gdx.files.internal("fnt/hwhp.fnt"));

//        generator = new FreeTypeFontGenerator(Gdx.files.internal("font/simhei.ttf"));//ttf字体
//        font = new SmartFont(generator, 30);
    }

    @Override
    public void render() {
        if (Gdx.input.isKeyPressed(Input.Keys.NUM_1)) {
             MyGdxGame.defaultGameStatus=1;
        }
        if (Gdx.input.isKeyPressed(Input.Keys.NUM_2)) {
            MyGdxGame.defaultGameStatus=2;
        }
        if (Gdx.input.isKeyPressed(Input.Keys.NUM_3)) {
            MyGdxGame.defaultGameStatus=0;
        }
        super.render();
        setScreen();

    }

    @Override
    public void dispose() {
        super.dispose();
        batch.dispose();
    }

    public void setScreen(){
        switch (defaultGameStatus) {
            case 1:
                setScreen(new MainScreen(this));
                break;
            case 2:
                setScreen(new EndScreen(this));
                break;
            default:
                setScreen(new StartScreen(this));
                break;
        }
    }
}
